package com.zhang.config;

import com.zhang.domain.TestBean;
import com.zhang.domain.TestBean2;
import com.zhang.domain.TestBean3;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.client.RestTemplate;

@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@Import({TestBean2.class, TestBean3.class})
@EnableConfigurationProperties({Lupenglin.class})
@ConditionalOnProperty(prefix = "lpl.info", name = "disable", havingValue = "true",matchIfMissing = false)
public class ApplicationContextConfig {

    @Autowired
    private Lupenglin lupenglin;

    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

    @Bean
    public TestBean testBean(RestTemplate restTemplate) {
        System.out.println(restTemplate);
        System.out.println(lupenglin.toString());
        return new TestBean();
    }

}
